package merisis.experiments.gcs;

/**
 * The Standard Binary Search Algorithm.
 * 
 * @author Chenggong Lv
 * 
 */
public class GCSearch0 extends AbstractGuessComplemetSearch {

	public long searchAlgoritm(long start, long end, long key) {

		long low = start;
		long high = end;

		while (low <= high) {

			long jump = (low + high) >>> 1;
			long jumpVal = access(jump);

			if (jumpVal < key)
				low = jump + 1;
			else if (jumpVal > key)
				high = jump - 1;
			else
				return jump; // key found
		}
		return -(low + 1); // key not found.
	}
}
